var echartsTheme = 'macarons';

var myQygm = {
    ids: {
        idnzTable: "table_zg",
        idfpTable: "table_fp",
        idxgzc: "table_xgzcwj"
    },
    charts: {
        yxswxsChart: null,
        jmztqkChart: null,
        zycszbChart: null,
        srgcChart: null,
        jbxxCcxxChart: null
    },
    tabes: {
        nzTable: null,
        xgzcTable: null,
        fpTable: null
    },
    search: function () {
        var lay = layer.load({shade: [0.1]});
        $.ajax({
            url: ctx + "/mge/adx/syfx/qyhx/getQyxx",
            data: $("#from_rd").formSerialize(),
            type: 'post',
            dataType: 'json',
            success: function (data, sta) {
                layer.close(lay);
                if (data != null && data.code == '200') {
                    var dc = data.data;
                    if (dc != null) {
                        for (var d in dc) {
                            var vd = $("#d_" + d);
                            if (vd.length > 0) {
                                if (cmm.isNullorEmpty(dc[d])) {
                                    $("#d_" + d).html(dc[d]);
                                } else {
                                    $("#d_" + d).html("-");
                                }
                            }
                        }
                        $("#djxh").val(dc.djxh);
                        myQygm.rdFbxxTable();
                        myQygm.rdZgTable();
                        var at = $("#qygl .active a");
                        tabDataShow(at);

                    } else {
                        layer.alert("没有查到该户信息！");
                    }
                } else {
                    layer.alert(data.message);
                }
            }, error: function (sta) {
                layer.close(lay);
                layer.alert("请求失败，请重试或检查网络！");
            }
        });
    },
    rdFbxxTable: function () {
        if (myQygm.tabes.fpTable) {
            myQygm.tabes.fpTable.refresh(myQygm.queryParams());
        } else {
            var bs = new BgdataTable();
            var opt = new BgOption(myQygm.ids.idfpTable, ctx + "/mge/adx/syfx/qyhx/queryRdxxFppzhd?rad=" + new Date().getTime(), [[
                {
                    title: '发票种类', field: 'fpzlmc', width: "300px", align: 'left', halign: 'center', valign: 'middle'
                }, {
                    title: '最高开票限额', field: 'dffpzgkpxe', width: "200px", align: 'center', valign: 'middle', formatter: function (v) {
                        return v;
                    }
                }, {
                    title: '持票最高数量', field: 'cpzgsl', width: "100px", align: 'center', valign: 'middle', formatter: function (v) {
                        return v;
                    }
                }, {
                    title: '每月购票最高数量', field: 'myzggpsl', width: "100px", align: 'center', valign: 'middle', formatter: function (v) {
                        return v;
                    }
                }
            ]], myQygm.queryParams(), null);
            opt.toolbarId = null;
            opt.showColumns = false;
            opt.showRefresh = false;
            opt.onLoadSuccess = function (data) {
                $(".pagination-detail").hide();
            }
            bs.draw(opt);
            myQygm.tabes.fpTable = bs;
        }
    },
    rdZgTable: function () {
        if (myQygm.tabes.nzTable) {
            myQygm.tabes.nzTable.refresh(myQygm.queryParams());
        } else {
            var bs = new BgdataTable();
            var opt = new BgOption(myQygm.ids.idnzTable, ctx + "/mge/adx/syfx/qyhx/queryRdxxNsrlx?rad=" + new Date().getTime(), [[
                {
                    title: '纳税人资格类型', field: 'nsrzglx', width: "300px", halign: 'center', align: 'left', valign: 'middle'
                }, {
                    title: '认定日期', field: 'lrrq', width: "100px", align: 'center', valign: 'middle', formatter: function (v) {
                        return v;
                    }
                }, {
                    title: '认定有效期起', field: 'yxqq', width: "100px", align: 'center', valign: 'middle', formatter: function (v) {
                        return v;
                    }
                }, {
                    title: '认定有效期止', field: 'yxqz', width: "100px", align: 'center', valign: 'middle', formatter: function (v) {
                        return v;
                    }
                }
            ]], myQygm.queryParams(), null);
            opt.showColumns = false;
            opt.showRefresh = false;
            opt.onLoadSuccess = function (data) {
                $(".pagination-detail").hide();
            }
            opt.toolbarId = null;
            bs.draw(opt);
            myQygm.tabes.nzTable = bs;
        }
    },
    jbxx_ccxxEchart: function () {
        if (myQygm.charts.jbxxCcxxChart) {
            return;
        }

        if ($("#djxh").val() == '') {
            return;
        }
        $.ajax({
            url: ctx + "/mge/adx/syfx/qyhx/queryCcxx",
            data: $("#from_rd").formSerialize(),
            type: 'post',
            dataType: 'json',
            success: function (d, sta) {
                if (d != null && d.code == "200") {
                    var data = d.data;
                    var colorTemplate1 = [[1, '#00a2e8']];
                    if (data == null || data.length == 0) {
                        $('#eh_ccxx').html("<img src='" + ctx + "/static/img/nodata.jpg' style='width: 100%;height: 100%' />");
                        return;
                    }
//                    var echartsTheme = 'macarons';
                    myQygm.charts.jbxxCcxxChart = echarts.init($('#eh_ccxx')[0], {
                        renderer: "canvas"
                    });
                    var option = ccxxOption(data);
                    myQygm.charts.jbxxCcxxChart.setOption(option);
                } else {
                    $('#eh_ccxx').html("生成失败！");
                }
            }, error: function (sta) {
                $('#eh_ccxx').html("生成失败AA！");
            }
        });


    },
    clearAll: function () {
        myQygm.charts.yxswxsChart.clear();
        if (myQygm.charts.yxswxsChart.isDisposed()) {
            myQygm.charts.yxswxsChart.dispose();
        }
        myQygm.charts.jmztqkChart.clear();
        if (myQygm.charts.jmztqkChart.isDisposed()) {
            myQygm.charts.jmztqkChart.dispose();
        }
        $('#eh_yxswxs').html("");
        $('#eh_jmztqk').html("");
    },
    ssjm_yxswxsEchart: function (data) {
        // if (data == null || data.length == 0) {
        //     $("#yxl_bq_je").html("");
        //     $("#yxl_yts_je").html("");
        //     $('#eh_yxswxs').html("<img src='" + ctx + "/static/img/nodata.jpg' style='width: 100%;height: 100%' />");
        //     return;
        // } else {
        var rkse = 0;
        var ybtse = 0;
        var ytzrkbl = 0;
        if (data != null && data.length > 0) {
            rkse = data[0].rkse;
            ybtse = data[0].ybtse;
            ytzrkbl = data[0].ytzrkbl
        }
        $("#yxl_bq_je").html(rkse);
        $("#yxl_yts_je").html(ybtse);
        if (myQygm.charts.yxswxsChart) {
            myQygm.charts.yxswxsChart.clear();
            var option = ybtOption(toFixed(ytzrkbl, 100), '应退占入库比');
            myQygm.charts.yxswxsChart.setOption(option);
        } else {
            myQygm.charts.yxswxsChart = echarts.init($('#eh_yxswxs')[0], {
                renderer: "canvas",
                width: 100,
                height: 200
            });
            var option = ybtOption(toFixed(ytzrkbl, 100), '应退占入库比');
            myQygm.charts.yxswxsChart.setOption(option);
        }
        // }
    }, ssjm_jmztqkEchart: function (data) {
        // if (data == null || data.length == 0) {
        //     $("#yxl_mz_je").html("");
        //     $("#yxl_jm_je").html("");
        //     $('#eh_jmztqk').html("<img src='" + ctx + "/static/img/nodata.jpg' style='width: 100%;height: 100%' />");
        //     return;
        // } else {
        var bqjmse = 0;
        var ljjmse = 0;
        var jmzrkbl = 0;
        if (data != null && data.length > 0) {
            bqjmse = data[0].bqjmse;
            ljjmse = data[0].ljjmse;
            jmzrkbl = data[0].jmzrkbl;
        }
        $("#yxl_mz_je").html(bqjmse);
        $("#yxl_jm_je").html(ljjmse);
        if (myQygm.charts.jmztqkChart) {
            myQygm.charts.jmztqkChart.clear();
            var option = ybtOption(toFixed(jmzrkbl, 100), '减免占应征比');
            myQygm.charts.jmztqkChart.setOption(option);
        } else {
            myQygm.charts.jmztqkChart = echarts.init($('#eh_jmztqk')[0], {
                renderer: "canvas",
                width: 100,
                height: 200
            });
            var option = ybtOption(toFixed(jmzrkbl, 100), '减免占应征比');
            myQygm.charts.jmztqkChart.setOption(option);
        }
        // }
    }, ssjm_xgzcwjTable: function () {
        if ($("#djxh").val() == '') {
            return;
        }
        if (myQygm.tabes.xgzcTable) {
            myQygm.tabes.xgzcTable.refresh(myQygm.queryParams());
        } else {
            var bs = new BgdataTable();
            var opt = new BgOption(myQygm.ids.idxgzc, ctx + "/mge/adx/syfx/qyhx/queryXgzcwj?rad=" + new Date().getTime(), [[
                {
                    title: '文号', field: 'wh', width: "100px", align: 'left', halign: 'center', valign: 'middle'
                }, {
                    title: '税收减免文件名称', field: 'ssjmwjmc', width: "200px", align: 'left', halign: 'center', valign: 'middle', formatter: function (v) {
                        return v;
                    }
                }, {
                    title: '发文单位', field: 'fwdw', width: "200px", align: 'center', valign: 'middle', formatter: function (v) {
                        return v;
                    }
                }
            ]], myQygm.queryParams(), null);
            opt.showColumns = false;
            opt.showRefresh = false;
            opt.paginationType = "client";
            opt.onLoadSuccess = function (data) {
                $(".pagination-detail").hide();
            }
            opt.toolbarId = null;
            bs.draw(opt);
            myQygm.tabes.xgzcTable = bs;
        }
    }, cwzk_zycszbEchart: function (data) {
        if (data.length > 0) {
            var myChart = echarts.init(document.getElementById('eh_zycszb'), echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts.zycszbChart = myChart;
            var bq = [];
            if (data.length > 0) {
                var bqz = data[0];
                bq.push(cmm.isNUllZro(bqz.zczb));
                bq.push(cmm.isNUllZro(bqz.xse));
                bq.push(cmm.isNUllZro(bqz.lrze));
                bq.push(cmm.isNUllZro(bqz.nsje));
                bq.push(cmm.isNUllZro(bqz.qsje));
                bq.push(cmm.isNUllZro(bqz.jmse));
            }
            myChart.setOption(zycszbOption(bq));
        } else {
            $("#eh_zycszb").html(myQygm.tipTbms(myQygm.getMsxx("CWZK01")));
            $("#eh_zycszb").css({"height": 80, "display": "table"});
            $("#eh_zycszb").prev().css("display", "none");
        }
    }, cwzk_srgcEchart: function (data) {
        // if (data.length > 0) {
        if (myQygm.charts.srgcChart) {
            myQygm.charts.srgcChart.clear();
            myQygm.charts.srgcChart.setOption(srgcOption(data.length > 0 ? data[0] : null));
        } else {
            var myChart = echarts.init(document.getElementById('eh_srgc'), echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts.srgcChart = myChart;
            myQygm.charts.srgcChart.setOption(srgcOption(data.length > 0 ? data[0] : null));
        }
        // } else {
        //     $("#eh_srgc").html("<img src='" + ctx + "/static/img/nodata.jpg' style='width: 100%;height: 100%' />");
        // }
    }, cwzk_yynlEchart: function (data) {
        var yszk = $("#eh_yynl_yszk");
        yszk.parent().show();
        if (myQygm.charts["yynlYszkEchart"]) {
            myQygm.charts["yynlYszkEchart"].clear();
            myQygm.charts["yynlYszkEchart"].setOption(ybtOption(toFixed((data.length > 0 && cmm.isNotNull(data[0].yszkzzl)) ? data[0].yszkzzl : 0, 100), "应收账款周转率"));
        } else {
            myQygm.charts["yynlYszkEchart"] = echarts.init(yszk[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["yynlYszkEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].yszkzzl) ? data[0].yszkzzl : 0, 100), "应收账款周转率"));
        }
        $("#eh_yynl_yszk").parent().append("<div  style='margin-top: -20px;'>" + myQygm.tipTbms(myQygm.getTbgs("CWZK03"), "tip-violet", "100%", "margin-left: -8px;left: 50%;") + "</div>");

        var ch = $("#eh_yynl_ch");
        ch.parent().show();
        if (myQygm.charts["yynlchEchart"]) {
            myQygm.charts["yynlchEchart"].clear();
            myQygm.charts["yynlchEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].chzzl) ? data[0].chzzl : 0, 100), "存货周转率"));
        } else {
            myQygm.charts["yynlchEchart"] = echarts.init(ch[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["yynlchEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].chzzl) ? data[0].chzzl : 0, 100), "存货周转率"));
        }
        $("#eh_yynl_ch").parent().append("<div  style='margin-top: -20px;'>" + myQygm.tipTbms(myQygm.getTbgs("CWZK04"), "tip-violet", "100%", "margin-left: -8px;left: 50%;") + "</div>")

        var gdzc = $("#eh_yynl_gdzc");
        gdzc.parent().show();
        if (myQygm.charts["yynlgdzcEchart"]) {
            myQygm.charts["yynlgdzcEchart"].clear();
            myQygm.charts["yynlgdzcEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].gdzczzl) ? data[0].gdzczzl : 0, 100), "固定资产周转率"));
        } else {
            myQygm.charts["yynlgdzcEchart"] = echarts.init(gdzc[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["yynlgdzcEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].gdzczzl) ? data[0].gdzczzl : 0, 100), "固定资产周转率"));
        }
        $("#eh_yynl_gdzc").parent().append("<div  style='margin-top: -20px;'>" + myQygm.tipTbms(myQygm.getTbgs("CWZK05"), "tip-violet", "100%", "margin-left: -8px;left: 50%;") + "</div>")

    }, cwzk_ylnlEchart: function (data) {
        // if (data.length > 0) {
        var yszk = $("#eh_ylnl_ml");
        yszk.parent().show();
        if (myQygm.charts["yynlmlEchart"]) {
        } else {
            myQygm.charts["yynlmlEchart"] = echarts.init(yszk[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["yynlmlEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].mll) ? data[0].mll : 0, 100), "毛利率"));
        }
        $("#eh_ylnl_ml").parent().append("<div style='margin-top: -20px;'>" + myQygm.tipTbms(myQygm.getTbgs("CWZK06"), "tip-violet", "100%", "margin-left: -8px;left: 50%;") + "</div>")

        var yylr = $("#eh_ylnl_yylr");
        yylr.parent().show();
        if (myQygm.charts["yynlyylrEchart"]) {
            myQygm.charts["yynlyylrEchart"].clear();
            myQygm.charts["yynlyylrEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].yylrl) ? data[0].yylrl : 0, 100), "营业利润率"));
        } else {
            myQygm.charts["yynlyylrEchart"] = echarts.init(yylr[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["yynlyylrEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].yylrl) ? data[0].yylrl : 0, 100), "营业利润率"));
        }
        $("#eh_ylnl_yylr").parent().append("<div style='margin-top: -20px;'>" + myQygm.tipTbms(myQygm.getTbgs("CWZK07"), "tip-violet", "100%", "margin-left: -8px;left: 50%;") + "</div>")

    }, cwzk_cznlEchart: function (data) {
        // if (data.length > 0) {
        var yszk = $("#eh_cznl_ldbl");
        yszk.parent().show();
        if (myQygm.charts["cznlldblEchart"]) {
            myQygm.charts["cznlldblEchart"].clear();
            myQygm.charts["cznlldblEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].ldbl) ? data[0].ldbl : 0, 100), "流动比率"));
        } else {
            myQygm.charts["cznlldblEchart"] = echarts.init(yszk[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["cznlldblEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].ldbl) ? data[0].ldbl : 0, 100), "流动比率"));
        }
        $("#eh_cznl_ldbl").parent().append("<div  style='margin-top: -20px;'>" + myQygm.tipTbms(myQygm.getTbgs("CWZK08"), "tip-violet", "100%", "margin-left: -8px;left: 50%;") + "</div>")

        var yylr = $("#eh_cznl_sdbl");
        yylr.parent().show();
        if (myQygm.charts["cznlsdblEchart"]) {
            myQygm.charts["cznlsdblEchart"].clear();
            myQygm.charts["cznlsdblEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].sdbl) ? data[0].sdbl : 0, 100), "速动比率"));
        } else {
            myQygm.charts["cznlsdblEchart"] = echarts.init(yylr[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["cznlsdblEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].sdbl) ? data[0].sdbl : 0, 100), "速动比率"));
        }
        $("#eh_cznl_sdbl").parent().append("<div  style='margin-top: -20px;'>" + myQygm.tipTbms(myQygm.getTbgs("CWZK09"), "tip-violet", "100%", "margin-left: -8px;left: 50%;") + "</div>")

        var zcfzl = $("#eh_cznl_zcfzl");
        zcfzl.parent().show();
        if (myQygm.charts["cznlzcfzlEchart"]) {
            myQygm.charts["cznlzcfzlEchart"].clear();
            myQygm.charts["cznlzcfzlEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].zcfzl) ? data[0].zcfzl : 0, 100), "资产负债率"));
        } else {
            myQygm.charts["cznlzcfzlEchart"] = echarts.init(zcfzl[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["cznlzcfzlEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].zcfzl) ? data[0].zcfzl : 0, 100), "资产负债率"));
        }
        $("#eh_cznl_zcfzl").parent().append("<div  style='margin-top: -20px;'>" + myQygm.tipTbms(myQygm.getTbgs("CWZK10"), "tip-violet", "100%", "margin-left: -8px;left: 50%;") + "</div>")

    }, cwzk_ylzlEchart: function (data) {
        var yszk = $("#eh_ylzl_yycbl");
        yszk.parent().show();
        myQygm.charts["ylzlyycblEchart"] = echarts.init(yszk[0], echartsTheme, {
            renderer: "canvas"
        });
        myQygm.charts["ylzlyycblEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].yycbl) ? data[0].yycbl : 0, 0, 100), "营业成本率"));
        $("#eh_ylzl_yycbl").parent().append("<div  style='margin-top: -20px;'>" + myQygm.tipTbms(myQygm.getTbgs("CWZK11"), "tip-violet", "100%", "margin-left: -8px;left: 50%;") + "</div>")

        var yylr = $("#eh_ylzl_cbfylyl");
        yylr.parent().show();
        myQygm.charts["ylzlcbfylylEchart"] = echarts.init(yylr[0], echartsTheme, {
            renderer: "canvas"
        });
        myQygm.charts["ylzlcbfylylEchart"].setOption(ybtOption(toFixed(data.length > 0 && cmm.isNotNull(data[0].cbfylyl) ? data[0].cbfylyl : 0, 100), "成本费用利用率"));
        $("#eh_ylzl_cbfylyl").parent().append("<div  style='margin-top: -20px;'>" + myQygm.tipTbms(myQygm.getTbgs("CWZK12"), "tip-violet", "100%", "margin-left: -8px;left: 50%;") + "</div>")

    }, sstz_zyzb: function (data) {
        // if (data.length > 0) {
        var v = $("#eh_sstz_qsbhl");
        // if (data[0].qsjebhl != null) {
        var qsjebhl = 0;
        if (data.length > 0 && data[0].qsjebhl != null) {
            qsjebhl = data[0].qsjebhl;
        }
        v.parent().show();
        if (myQygm.charts["sstzqsbhlEchart"]) {
            myQygm.charts["sstzqsbhlEchart"].clear();
            myQygm.charts["sstzqsbhlEchart"].setOption(ybtOption(toFixed(qsjebhl, 100), "欠税金额变化率"));
        } else {
            myQygm.charts["sstzqsbhlEchart"] = echarts.init(v[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["sstzqsbhlEchart"].setOption(ybtOption(toFixed(qsjebhl, 100), "欠税金额变化率"));
        }
        // } else {
        //     v.parent().hide();
        // }
        var p = $("#eh_sstz_cbsktz");
        // if (data[0].cbskbl != null) {
        p.parent().show();
        var cbskbl = 0;
        if (data.length > 0 && data[0].cbskbl) {
            cbskbl = data[0].cbskbl;
        }
        if (myQygm.charts["sstzcbsktzEchart"]) {
            myQygm.charts["sstzcbsktzEchart"].clear();
            myQygm.charts["sstzcbsktzEchart"].setOption(ybtOption(toFixed(cbskbl, 100), "查补税款比重"));
        } else {
            myQygm.charts["sstzcbsktzEchart"] = echarts.init(p[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["sstzcbsktzEchart"].setOption(ybtOption(toFixed(cbskbl, 100), "查补税款比重"));
        }
        // } else {
        //     p.parent().hide();
        // }
        // } else {
        //     $("#eh_sstz_cbsktz").html("<img src='" + ctx + "/static/img/nodata.jpg' style='width: 100%;height: 100%' />");
        //     $("#eh_sstz_qsbhl").html("<img src='" + ctx + "/static/img/nodata.jpg' style='width: 100%;height: 100%' />");
        // }
    }, sstz_jynqs: function (data) {
        if (data != null && data.length > 0) {
            var ny = [];
            var xssrs = [];
            var zzsjes = [];
            if (data != null && data.length > 0) {
                for (var f in data) {
                    ny.push(data[f].ny);
                    xssrs.push(data[f].xssr);
                    zzsjes.push(data[f].sssr);
                }
            }
            var v = $("#eh_sstz_jynjyzk");
            $("#zsslt a").on('click', function (e) {
                e.preventDefault();
                if ($(this).data("lx") == "1") {
                    $("#zsnrbt").html("销售收入");
                    myQygm.charts["sstzjynjyzkEchart"].clear();
                    myQygm.charts["sstzjynjyzkEchart"].setOption(lineOption(ny, xssrs, "销售收入"));
                } else {
                    $("#zsnrbt").html("税收收入");
                    myQygm.charts["sstzjynjyzkEchart"].clear();
                    myQygm.charts["sstzjynjyzkEchart"].setOption(lineOption(ny, zzsjes, "税收收入"));
                }
            });
            myQygm.charts["sstzjynjyzkEchart"] = echarts.init(v[0], echartsTheme, {
                renderer: "canvas"
            });
            myQygm.charts["sstzjynjyzkEchart"].setOption(lineOption(ny, xssrs, "销售收入"));
        } else {
            $("#eh_sstz_jynjyzk").html(myQygm.tipTbms(myQygm.getMsxx("SSTZ03")));
            $("#eh_sstz_jynjyzk").css({"height": 80, "display": "table"});
            $("#eh_sstz_jynjyzk").prev().css("display", "none");
        }
    }, sstz_jynswxw: function (data) {
        $("#eh_sstz_jynswxw").html("");
        if (cmm.isNotNull(data) && data.length > 0) {
            var h = "";
            h += "<p>连续三个月零税额申报次数" + data[0].lxlse + "</p>";
            h += "<p>连续三个月零适用税率征收申报次数" + data[0].lxlsl + "</p>";
            h += "<p>逾期未申报次数" + data[0].yqwsb + "</p>";
            h += "<p>逾期未缴款次数" + data[0].yqwjk + "</p>";
            h += "<p>税收违法违章次数" + data[0].sswfwz + "</p>";
            $("#eh_sstz_jynswxw").html(h);
        } else {
            $("#eh_sstz_jynswxw").html("<img src='" + ctx + "/static/img/nodata.jpg' style='width: 100%;height: 100%' />");
        }
    }, sstz_jcjbsr: function (data) {
        if (cmm.isNotNull(data) && data.length > 0) {
            var v = $("#eh_sstz_jccbsrjg");
            if (myQygm.charts["sstzjccbsrjgEchart"]) {
                myQygm.charts["sstzjccbsrjgEchart"].clear();
                myQygm.charts["sstzjccbsrjgEchart"].setOption(jcsrOption(data[0]));
            } else {
                myQygm.charts["sstzjccbsrjgEchart"] = echarts.init(v[0], echartsTheme, {
                    renderer: "canvas"
                });
                myQygm.charts["sstzjccbsrjgEchart"].setOption(jcsrOption(data[0]));
            }
        } else {
            $("#eh_sstz_jccbsrjg").html(myQygm.tipTbms(myQygm.getMsxx("SSTZ04")));
            $("#eh_sstz_jccbsrjg").css({"height": 80, "display": "table"});
        }
    }, fpxx_fpslhje: function (data) {
        if (cmm.isNotNull(data) && data.length > 0) {
            var zpfsbl = 0;
            var ppfsbl = 0;
            var zpjebl = 0;
            var ppjebl = 0;
            var fpzfs = 0;
            var zpfs = 0;
            var ppfs = 0;
            var kpzje = 0;
            var zpje = 0;
            var ppje = 0;
            if (cmm.isNotNull(data) && data.length > 0) {
                zpfsbl = data[0].zpfsbl;
                ppfsbl = data[0].ppfsbl;
                zpjebl = data[0].zpjebl;
                ppjebl = data[0].ppjebl;
                fpzfs = data[0].fpzfs;
                zpfs = data[0].zpfs;
                ppfs = data[0].ppfs;
                kpzje = data[0].kpzje;
                zpje = data[0].zpje;
                ppje = data[0].ppje;
            }
            var v = $("#eh_fpxx_fpsltj");
            var f = [
                {value: zpfs, name: '专用发票'},
                {value: ppfs, name: '普通发票'}
            ]
            if (myQygm.charts["fpxxfpsltjEchart"]) {
                myQygm.charts["fpxxfpsltjEchart"].clear();
                myQygm.charts["fpxxfpsltjEchart"].setOption(fptjOption(f, "个"));
            } else {
                myQygm.charts["fpxxfpsltjEchart"] = echarts.init(v[0], echartsTheme, {
                    renderer: "canvas"
                });
                myQygm.charts["fpxxfpsltjEchart"].setOption(fptjOption(f, "个"));
            }

            // var sl = " <p>开具发票数量：" + cmm.emptyVal(fpzfs) + "份数</p>"
            //     + "<p>增值税专用发票：" + cmm.emptyVal(zpfs) + "份数</p>"
            //     + "<p>增值税普通发票：" + cmm.emptyVal(ppfs) + "份数</p>";
            $("#fpxxsltj").html("");

            var v = $("#eh_fpxx_fpjetj");
            var d = [
                {value: zpje, name: '专用发票'},
                {value: ppje, name: '普通发票'}
            ];
            if (myQygm.charts["fpxxfpjetjEchart"]) {
                myQygm.charts["fpxxfpjetjEchart"].clear();
                myQygm.charts["fpxxfpjetjEchart"].setOption(fptjOption(d, "元"));
            } else {
                myQygm.charts["fpxxfpjetjEchart"] = echarts.init(v[0], echartsTheme, {
                    renderer: "canvas"
                });
                myQygm.charts["fpxxfpjetjEchart"].setOption(fptjOption(d, "元"));
            }
            // var je = " <p>开具发票金额：" + cmm.emptyVal(kpzje) + "元</p>"
            //     + "<p>增值税专用发票：" + cmm.emptyVal(zpje) + "元</p>"
            //     + "<p>增值税普通发票：" + cmm.emptyVal(ppje) + "元</p>";
            $("#fpxxjetj").html("");
        } else {
            $("#eh_fpxx_fpsltj").html(myQygm.tipTbms(myQygm.getMsxx("FPXX01")));
            $("#eh_fpxx_fpsltj").css({"height": 30, "display": "table"});
            $("#eh_fpxx_fpjetj").html(myQygm.tipTbms(myQygm.getMsxx("FPXX02")));
            $("#eh_fpxx_fpjetj").css({"height": 30, "display": "table"});
        }
    }, fpxx_kpzyzb: function (data) {
        if (cmm.isNotNull(data) && data.length > 1) {
            var v = $("#eh_fpxx_kpzyzb");
            var qybz = [];
            var hybz = [];
            if (cmm.isNotNull(data) && data.length > 1) {
                if (data[0].bz == "0") {
                    qybz.push(data[0].wkpje);
                    qybz.push(data[0].yjkpje);
                    qybz.push(data[0].dekpje);
                    qybz.push(data[0].zffpje);
                    hybz.push(data[1].wkpje);
                    hybz.push(data[1].yjkpje);
                    hybz.push(data[1].dekpje);
                    hybz.push(data[1].zffpje);
                } else {
                    qybz.push(data[1].wkpje);
                    qybz.push(data[1].yjkpje);
                    qybz.push(data[1].dekpje);
                    qybz.push(data[1].zffpje);
                    hybz.push(data[0].wkpje);
                    hybz.push(data[0].yjkpje);
                    hybz.push(data[0].dekpje);
                    hybz.push(data[0].zffpje);
                }
            }
            if (myQygm.charts["fpxxkpzyzbEchart"]) {
                myQygm.charts["fpxxkpzyzbEchart"].clear();
                myQygm.charts["fpxxkpzyzbEchart"].setOption(kpzyzbOption(qybz, hybz));
            } else {
                myQygm.charts["fpxxkpzyzbEchart"] = echarts.init(v[0], echartsTheme, {
                    renderer: "canvas"
                });
                myQygm.charts["fpxxkpzyzbEchart"].setOption(kpzyzbOption(qybz, hybz));
            }
        } else {
            $("#eh_fpxx_kpzyzb").html(myQygm.tipTbms(myQygm.getMsxx("FPXX03")));
            $("#eh_fpxx_kpzyzb").css({"height": 30, "display": "table"});
        }
    }, fpxx_xshjx: function (xsdata, jxdata) {
        var v = $("#eh_fpxx_xshw10");
        if (cmm.isNotNull(xsdata) && xsdata.length > 0) {
            var ax = [];
            var dx = [];

            for (var d in xsdata) {
                ax.push(xsdata[d].hwmc);
                dx.push(xsdata[d].je);
            }

            if (myQygm.charts["fpxxxshw10Echart"]) {
                myQygm.charts["fpxxxshw10Echart"].clear();
                myQygm.charts["fpxxxshw10Echart"].setOption(xshjxOption(ax, dx));
            } else {
                myQygm.charts["fpxxxshw10Echart"] = echarts.init(v[0], echartsTheme, {
                    renderer: "canvas"
                });
                myQygm.charts["fpxxxshw10Echart"].setOption(xshjxOption(ax, dx));
            }
        } else {
            $("#eh_fpxx_xshw10").html(myQygm.tipTbms(myQygm.getMsxx("FPXX04")));
            $("#eh_fpxx_xshw10").css({"height": 30, "display": "table"});
        }
        var f = $("#eh_fpxx_jxhw10");
        if (cmm.isNotNull(jxdata) && jxdata.length > 0) {
            var ax2 = [];
            var dx2 = [];

            for (var d in jxdata) {
                ax2.push(jxdata[d].hwmc);
                dx2.push(jxdata[d].je);
            }

            if (myQygm.charts["fpxxjxhw10Echart"]) {
                myQygm.charts["fpxxjxhw10Echart"].clear();
                myQygm.charts["fpxxjxhw10Echart"].setOption(xshjxOption(ax2, dx2));
            } else {
                myQygm.charts["fpxxjxhw10Echart"] = echarts.init(f[0], echartsTheme, {
                    renderer: "canvas"
                });
                myQygm.charts["fpxxjxhw10Echart"].setOption(xshjxOption(ax2, dx2));
            }
        } else {
            $("#eh_fpxx_jxhw10").html(myQygm.tipTbms(myQygm.getMsxx("FPXX05")));
            $("#eh_fpxx_jxhw10").css({"height": 30, "display": "table"});
        }
    }, fpxx_xsghfx: function (xsdata, ghdata) {
        if (cmm.isNotNull(xsdata) && xsdata.length > 0) {
            var v = $("#eh_fpxx_xsdqfx");
            var dd = [];
            var total = 0;
            if (cmm.isNotNull(xsdata) && xsdata.length > 0) {
                for (var d in xsdata) {
                    dd.push({value: xsdata[d].je, name: xsdata[d].sfmc});
                    total += xsdata[d].je;
                }
            }
            if (myQygm.charts["fpxxxsdqfxEchart"]) {
                myQygm.charts["fpxxxsdqfxEchart"].clear();
                myQygm.charts["fpxxxsdqfxEchart"].setOption(xhghfxOption(dd, total));
            } else {
                myQygm.charts["fpxxxsdqfxEchart"] = echarts.init(v[0], echartsTheme, {
                    renderer: "canvas"
                });
                myQygm.charts["fpxxxsdqfxEchart"].setOption(xhghfxOption(dd, total));
            }
        } else {
            $("#eh_fpxx_xsdqfx").html(myQygm.tipTbms(myQygm.getMsxx("FPXX06")));
            $("#eh_fpxx_xsdqfx").css({"height": 30, "display": "table"});
        }
        if (cmm.isNotNull(ghdata) && ghdata.length > 0) {
            var f = $("#eh_fpxx_ghdqfx");
            var pp = [];
            var total = 0;
            if (cmm.isNotNull(ghdata) && ghdata.length > 0) {
                for (var d in ghdata) {
                    pp.push({value: ghdata[d].je, name: ghdata[d].sfmc});
                    total += ghdata[d].je;
                }
            }
            if (myQygm.charts["fpxxghdqfxEchart"]) {
                myQygm.charts["fpxxghdqfxEchart"].clear();
                myQygm.charts["fpxxghdqfxEchart"].setOption(xhghfxOption(pp, total));
            } else {
                myQygm.charts["fpxxghdqfxEchart"] = echarts.init(f[0], echartsTheme, {
                    renderer: "canvas"
                });
                myQygm.charts["fpxxghdqfxEchart"].setOption(xhghfxOption(pp, total));
            }
        } else {
            $("#eh_fpxx_ghdqfx").html(myQygm.tipTbms(myQygm.getMsxx("FPXX07")));
            $("#eh_fpxx_ghdqfx").css({"height": 30, "display": "table"});
        }
    }, getMsxx: function (n) {
        for (var m in msxx) {
            var xm = msxx[m];
            if (xm["tbbh"] == n) {
                return "暂无数据。<br/>说明：" + xm["tbsm"];
            }
        }
        return "";
    }, getTbgs: function (n) {
        for (var m in tbsm) {
            var xm = tbsm[m];
            if (xm["tbbh"] == n) {
                return xm["tbsm"];
            }
        }
        return "";
    }, cwzk: function () {//财务状况
        if ($("#portlet_cwzk").attr("data-init") == "false") {
            if ($("#djxh").val() != "") {
                var lay = layer.load({shade: [0.1]});
                $.ajax({
                    url: ctx + "/mge/adx/syfx/qyhx/queryCwzk",
                    data: $("#from_rd").formSerialize(),
                    type: "post", dataType: "json", success: function (data, sta) {
                        layer.close(lay);
                        if (data != null && data.code == '200') {
                            myQygm.cwzk_zycszbEchart(data.data.zycszb);
                            myQygm.cwzk_srgcEchart(data.data.ssgc);
                            myQygm.cwzk_yynlEchart(data.data.yynl);
                            myQygm.cwzk_ylnlEchart(data.data.ylnl);
                            myQygm.cwzk_cznlEchart(data.data.cznl);
                            myQygm.cwzk_ylzlEchart(data.data.ylzl);
                            $("#portlet_cwzk").attr("data-init", "true");
                        } else {
                            layer.alert('财务状况加载失败!');
                        }
                    }, error: function (sta) {
                        layer.close(lay);
                        layer.alert("请求失败，请重试或检查网络！");
                    }
                })
            }
        }
    },
    ssjm: function () {
        if ($("#portlet_ssjm").attr("data-init") == "false") {
            if ($("#djxh").val() != "") {
                var lay = layer.load({shade: [0.1]});
                $.ajax({
                    url: ctx + "/mge/adx/syfx/qyhx/querySsjm",
                    data: $("#from_rd").formSerialize(),
                    type: "post", dataType: "json", success: function (data, sta) {
                        layer.close(lay);
                        if (data != null && data.code == '200') {
                            myQygm.ssjm_yxswxsEchart(data.data.Txwxqk);
                            myQygm.ssjm_jmztqkEchart(data.data.Jmztqk);
                            myQygm.ssjm_xgzcwjTable();
                            $("#portlet_ssjm").attr("data-init", "true");
                        } else {
                            layer.alert("加载税收减免失败！");
                        }
                    }, error: function (sta) {
                        layer.close(lay);
                        layer.alert("请求失败，请重试或检查网络！");
                    }
                })
            }
        }
    },
    sstz: function () {
        if ($("#portlet_sstz").attr("data-init") == "false") {
            if ($("#djxh").val() != "") {
                var lay = layer.load({shade: [0.1]});
                $.ajax({
                    url: ctx + "/mge/adx/syfx/qyhx/querySstz",
                    data: $("#from_rd").formSerialize(),
                    type: 'post', dataType: 'json', success: function (data, sta) {
                        layer.close(lay);
                        if (data != null && data.code == "200") {
                            myQygm.sstz_jynqs(data.data.jynzk);
                            myQygm.sstz_zyzb(data.data.zyzb);
                            myQygm.sstz_jynswxw(data.data.jynswxw);
                            myQygm.sstz_jcjbsr(data.data.jcjbsr);
                            $("#portlet_sstz").attr("data-init", "true");
                        } else {
                            layer.alert("加载税收状态失败！");
                        }
                    }, error: function (st) {
                        layer.close(lay);
                        layer.alert("请求失败，请重试或检查网络！");
                    }
                })
            }
        }
    }, fpxx: function () {
        if ($("#portlet_fpgl").attr("data-init") == "false") {
            if ($("#djxh").val() != "") {
                var lay = layer.load({shade: [0.1]});
                $.ajax({
                    url: ctx + "/mge/adx/syfx/qyhx/queryFpxx",
                    data: $("#from_rd").formSerialize(),
                    type: 'post', dataType: 'json', success: function (data, sta) {
                        layer.close(lay);
                        if (data != null && data.code == "200") {
                            myQygm.fpxx_fpslhje(data.data.kjslhje);
                            myQygm.fpxx_kpzyzb(data.data.kpzyzb);
                            myQygm.fpxx_xsghfx(data.data.xhdqfx, data.data.ghdqfx);
                            myQygm.fpxx_xshjx(data.data.xshw, data.data.Jxhw);
                            $("#portlet_fpgl").attr("data-init", "true");
                        } else {
                            layer.alert("加载发票信息失败！");
                        }
                    }, error: function (st) {
                        layer.close(lay);
                        layer.alert("请求失败请重试或检查网络！");
                    }
                })
            }
        }
    },
    ssfx: function () {
        var lay = layer.load({shade: [0.1]});
        $.ajax({
            url: ctx + "/mge/adx/syfx/qyhx/queryFxfx",
            data: $("#from_rd").formSerialize(),
            type: 'post',
            dataType: "json",
            success: function (data) {
                layer.close(lay);
                if (data != null && data.code == '200') {
                    $("#fxfx_table").bootstrapTable({
                        columns: [[{title: '模型ID号', field: 'mxId', width: "100px", align: 'center', valign: 'middle'},
                            {title: '模型名称', field: 'fxmc', width: "300px", halign: 'center', align: 'left', valign: 'middle'},
                            {title: '涉及税种', field: 'sjsz', width: "100px", halign: 'center', align: 'center', valign: 'middle'},
                            {title: '疑点个数', field: 'sl', width: "100px", align: 'center', valign: 'middle'}
                        ]],
                        data: data.data
                    });
                    var ld = [];
                    var dl = [];
                    if (data.data.length > 0) {
                        for (var d in data.data) {
                            var row = data.data[d];
                            ld.push(row.fxmc);
                            dl.push({value: row.sl, name: row.fxmc});
                        }
                        var v = $("#eh_fxfx_ssfx");
                        if (myQygm.charts["fxfxssfxEchart"]) {
                            myQygm.charts["fxfxssfxEchart"].clear();
                            myQygm.charts["fxfxssfxEchart"].setOption(ssfxOption(ld, dl));
                        } else {
                            myQygm.charts["fxfxssfxEchart"] = echarts.init(v[0], echartsTheme, {
                                renderer: "canvas"
                            });
                            myQygm.charts["fxfxssfxEchart"].setOption(ssfxOption(ld, dl));
                        }
                    } else {
                        $("#eh_fxfx_ssfx").html(myQygm.tipTbms(myQygm.getMsxx("SSFX01")));
                        $("#eh_fxfx_ssfx").css({"height": 80, "display": "table"});
                    }
                } else {
                    layer.alert("生成风险分析失败！");
                }
            }, error: function (sta) {
                layer.close(lay);
                layer.alert("请求失败，请重试检查网络！");
            }
        });

    },
    qtxx: function () {
        var op = new BgOption("qtxx_table", ctx + "/mge/adx/syfx/qyhx/queryQtxx", [[{
            title: '数据分类',
            field: 'gl',
            width: "80px",
            align: 'center',
            valign: 'middle'
        }, {
            title: '数据说明',
            field: 'sjsm',
            width: "100px",
            align: 'center',
            valign: 'middle'
        }, {title: '数据详情', field: 'xq2', width: "350px", align: 'left', halign: 'center', valign: 'middle'}, {
            title: '录入日期',
            field: 'lrrq',
            width: "80px",
            align: 'center',
            valign: 'middle'
        }]], myQygm.queryParams(), 500);
        var bg = new BgdataTable();
        bg.draw(op);
    },
    qygm: function () {
        var lay = layer.load({shade: [0.1]});
        $.ajax({
            url: ctx + "/mge/adx/syfx/qyhx/queryQygm",
            data: $("#from_rd").formSerialize(),
            type: 'post',
            dataType: "json",
            success: function (data) {
                layer.close(lay);
                if (data != null && data.code == '200') {
                    var v = $("#qy_sunburst");
                    if (myQygm.charts["sunburstEchart"]) {
                        myQygm.charts["sunburstEchart"].clear();
                        myQygm.charts["sunburstEchart"].setOption(qySunburst(data));

                        //点击事件
                        myQygm.charts["sunburstEchart"].off('clear');
                        myQygm.charts["sunburstEchart"].on('click', function (e) {
                            //待修改2019/08/27
                            /*  var i=e.dataIndex;
                              if(i==3){
                                  $('#qy_sunburst2').show();
                              }else {
                                  alert(i);
                              }*/
                        });
                    } else {
                        myQygm.charts["sunburstEchart"] = echarts.init(v[0], echartsTheme, {
                            renderer: "canvas"
                        });
                        myQygm.charts["sunburstEchart"].setOption(qySunburst(data));

                        //点击事件
                        myQygm.charts["sunburstEchart"].off('clear');
                        myQygm.charts["sunburstEchart"].on('click', function (e) {
                            //待修改2019/08/27
                            //修改2019/09/05
                           if(e.data.djxh){
                              var djxh=e.data.djxh;
                               var bdDm=e.data.bdDm;
                                queryQyxxByDjxh(djxh,bdDm);
                           }

                        });
                    }

                }
            }, error: function (sta) {
                layer.close(lay);
            }
        });
    }, qyjzlfx: function () {
        barGo1();
        barGo2();
        zyywsrGo();
        zyywlrlGo();
        barGo3();
    }, queryParams: function () {
        return cmm.serializeObject($("#from_rd"));
    }
    ,
    collapse: function () {
        $('body').on('click', '.portlet > .portlet-title > .tools > .collapse, .portlet .portlet-title > .tools > .expand', function (e) {
            e.preventDefault();
            var el = $(this).closest(".portlet").children(".portlet-body");
            if ($(this).hasClass("collapse")) {
                $(this).removeClass("collapse").addClass("expand");
                el.slideUp(200);
            } else {
                $(this).removeClass("expand").addClass("collapse");
                el.slideDown(200);
            }
        });
    }
    ,
    getViewPort: function () {
        var e = window,
            a = 'inner';
        if (!('innerWidth' in window)) {
            a = 'client';
            e = document.documentElement || document.body;
        }

        return {
            width: e[a + 'Width'],
            height: e[a + 'Height']
        };
    },
    resize: function () {
        for (var chars in myQygm.charts) {
            if (myQygm.charts[chars]) {
                myQygm.charts[chars].resize();
            }
        }
    }, tipTbms: function (name, css, w, clr) {
        var cls = "tip-yellow";
        if (!css) {
            css = cls;
        }
        var wi = "300px";
        if (!w) {
            w = wi;
        }
        if (!clr) {
            clr = "";
        }
        var ms = '<div class="' + css + '"';
        var bag = 'background-image: url(' + ctx + '/static/js/poshytip-1.0/' + css + '/' + css + '.png);';
        if (cmm.isNullorEmpty(css) && css == "tip-violet") {
            bag = "";
            clr = clr + "background: transparent;";
        }
        ms += ' style="visibility: inherit; left: 0px; top: 0px; border: 0px;position: relative; padding: 0px; background-image: none; background-color: transparent; opacity: 1;">'
            + '<table border="0" cellpadding="0" cellspacing="0" style="width: ' + w + '">'
            + '<tbody>'
            + '<tr>'
            + ' <td class="tip-top tip-bg-image" colspan="2" style="' + bag + '"><span></span></td>'
            + '<td class="tip-right tip-bg-image" rowspan="2" style="' + bag + '"><span></span></td>'
            + '</tr>'
            + '<tr>'
            + '<td class="tip-left tip-bg-image" rowspan="2" style="' + bag + '"><span></span></td>'
            + '<td style="width: 100%;">'
            + '<div class="tip-inner tip-bg-image" style="' + bag + '">' + name + '</div>'
            + '</td>'
            + '</tr>'
            + '<tr>'
            + '<td class="tip-bottom tip-bg-image" colspan="2"' + 'style="' + bag + '"><span></span></td>'
            + '</tr>'
            + '</tbody>'
            + ' </table>'
            + '<div class="tip-arrow tip-arrow-top" style="visibility: inherit;' + clr + '"></div>'
            + '</div>';
        return ms;
    }
    ,
    fullscreen: function () {
        // handle portlet fullscreen
        $('body').on('click', '.portlet > .portlet-title .fullscreen', function (e) {
            e.preventDefault();
            var portlet = $(this).closest(".portlet");
            if (portlet.hasClass('portlet-fullscreen')) {
                $(this).removeClass('on');
                portlet.removeClass('portlet-fullscreen');
                $('body').removeClass('page-portlet-fullscreen');
                portlet.children('.portlet-body').css('height', 'auto');
            } else {
                var height = myQygm.getViewPort().height -
                    portlet.children('.portlet-title').outerHeight() -
                    parseInt(portlet.children('.portlet-body').css('padding-top')) -
                    parseInt(portlet.children('.portlet-body').css('padding-bottom'));

                $(this).addClass('on');
                portlet.addClass('portlet-fullscreen');
                $('body').addClass('page-portlet-fullscreen');
                portlet.children('.portlet-body').css('height', height);
            }
        });
    }
}
$(function () {
    $('.portlet > .portlet-title .fullscreen').tooltip({
        container: 'body',
        title: '最大化'
    });
    $('.portlet > .portlet-title > .tools > .collapse, .portlet > .portlet-title > .tools > .expand').tooltip({
        container: 'body',
        title: '展开/收缩'
    });
    $("#qygl a").on("click", function (e) {
        e.preventDefault();
        $(this).tab("show");
        tabDataShow($(this));
    });
    $("#cz").click(function () {
        window.location.href = ctx + '/mge/adx/qyhx/qygmcx';
    })
    myQygm.collapse();
    myQygm.fullscreen();
    myQygm.search();
    myQygm.qygm();
    //qySunburst();
    $(window).resize(function () {
        myQygm.resize();
    });
    qyms();
    qytbsm();

});
var msxx;
var tbsm;

function qytbsm() {
    $.ajax({
        url: ctx + "/mge/adx/syfx/qyhx/queryQyTbgs",
        data: {},
        type: 'post',
        dataType: 'json',
        success: function (data, sta) {
            if (data != null && data.code == '200') {
                tbsm = data.data;
            }
        }, error: function (sta) {

        }
    });
}

function qyms() {
    $.ajax({
        url: ctx + "/mge/adx/syfx/qyhx/queryQymksm",
        data: {},
        type: "post",
        dataType: "json",
        success: function (data, stat) {
            if (data != null && data.code == 200) {
                msxx = data.data;
            }
        }, error: function (sta) {

        }
    })
}

function toFixed(v, f) {
    var l = v * f;
    return l.toFixed(2);
}

var qyf = false;

function tabDataShow(t) {
    myQygm.resize();
    if (t.attr("href") == "#portlet_ssjm") {
        myQygm.ssjm();
    } else if (t.attr("href") == "#portlet_cwzk") {
        myQygm.cwzk();
    } else if (t.attr("href") == "#portlet_sstz") {
        myQygm.sstz();
    } else if (t.attr("href") == "#portlet_fpgl") {
        myQygm.fpxx();
    } else if (t.attr("href") == "#portlet_fxfx") {
        myQygm.ssfx();
    } else if (t.attr("href") == "#portlet_qtxx") {
        myQygm.qtxx();
    } else if (t.attr("href") == "#portlet_qyjzlfx") {
        if (!qyf) {
            myQygm.qyjzlfx();
        }
        qyf = true;
    } else if (t.attr("href") == '#portlet_jbxx') {
        myQygm.jbxx_ccxxEchart();
    }
}

function qySunburst(xr) {

    var colors = [

        ['#da0d68', '#e0719c', '#f99e1c'],
        ['#e75b68', '#dd4c51', '#6569b0'],
        ['#ebb40f', '#e1c315', '#8eb646'],
        ['#187a2f', '#a2b029', '#718933'],
        ['#0aa3b5', '#76c0cb', '#7a9bae'],
        ['#c94930', '#ddaf61', '#eb9d5f'],
        ['#ad213e', '#b14d57', '#e5762e'],
        ['#c78869', '#bb764c', '#692a19'],
        ['#e65832', '#d45a59', '#f89a80'],
        ['#b09733', '#b34039', '#a2bb2b']
    ];

    var ds = xr.data;
    var g1 = ds.g1;
    var g2 = ds.g2;
    var names = [];

    for (var g in g1) {
        var ist = false;
        for (var y in names) {
            if (names[y] == g1[g].dl) {
                ist = true;
                break;
            }
        }
        if (!ist) {
            names.push(g1[g].dl);
        }

    }
    var data = [];
    var c1 = 0;

    for (var d in names) {
        //第一层颜色
        var n = names[d];
        var p = {
            name: n, itemStyle: {
                color: colors[c1][0]
            }
        };
        var chl = [];
        p["children"] = chl;
        data.push(p);
        var c2 = 0;
        var c3;
        var f = 0;
        for (var f in g2) {
            var k = g2[f];
            if (k.dl == n) {
                if (c2 % 2 == 0) {
                    //基数
                    var ej = {

                        djxh:k.djxh,bdDm:k.bdDm,
                        itemStyle: {
                            color: colors[c1][0]
                        }
                    };
                    if (c2 % 2 == 0) {
                        c3 = colors[c1][1];
                    } else {
                        c3 = colors[c1][2];
                    }
                } else {

                    var ej = {
                        djxh:k.djxh,bdDm:k.bdDm,
                        itemStyle: {
                            color: colors[c1][1]
                        }
                    };
                    if (c2 % 2 == 0) {
                        c3 = colors[c1][1];
                    } else {
                        c3 = colors[c1][2];
                    }
                }

                var isf = false;

                for (var o in chl) {
                    if (chl[o]["name"] != null && chl[o]["name"] == k.xl) {
                        ej = chl[o];
                        isf = true;
                        break;
                    }
                }
                if (!isf) {
                    chl.push(ej);
                }

                if (ej["name"]) {
                    ej["children"].push({
                        name: cmm.strTWLen(k.xq, 10), an: k.xq, value: 1,djxh:k.djxh,bdDm:k.bdDm, itemStyle: {
                            color: c3
                        }
                    });
                } else {
                    ej["name"] = k.xl;
                    ej["children"] = [{
                        name: cmm.strTWLen(k.xq, 10), an: k.xq, value: 1,djxh:k.djxh, bdDm:k.bdDm,itemStyle: {
                            color: c3
                        }
                    }];
                }
                c2 = c2 + 1;
            }
        }
        c1 = c1 + 1;
    }

    var se = {
        type: 'sunburst',
        highlightPolicy: 'ancestor',
        data: data,
        radius: [0, '55%'],
        sort: null,
        label: {
            fontSize: 12
        },
        levels: [{}, {
            r0: '5%',
            r: '15%',
            itemStyle: {
                borderWidth: 2
            },
            label: {
                rotate: 'tangential'
            }
        }, {
            r0: '15%',
            r: '45%',
            label: {
                align: 'right'
            }
        }, {
            r0: '45%',
            r: '47%',
            label: {
                position: 'outside',
                // position: 'inside',
                padding: 3,
                silent: false,
                color: '#039BE5',
                borderWidth: 3
            },
            itemStyle: {
                borderWidth: 3
            }
        }]
    };
    var l = getDlLegth(xr);
    if (l > 3) {
        se = {
            type: 'sunburst',
            highlightPolicy: 'ancestor',
            data: data,
            radius: [0, '100%'],
            sort: null,
            label: {
                fontSize: 12
            },
            levels: [{}, {
                r0: '5%',
                r: '25%',
                itemStyle: {
                    borderWidth: 2
                },
                label: {
                    rotate: 'tangential'
                }
            }, {
                r0: '25%',
                r: '60%',
                label: {
                    align: 'right'
                }
            }, {
                r0: '60%',
                r: '62%',
                label: {
                    position: 'outside',
                    // position: 'inside',
                    padding: 3,
                    silent: false,
                    color: '#039BE5',
                    borderWidth: 3
                },
                itemStyle: {
                    borderWidth: 3
                }
            }]
        };

    }

    var option = {

        title: {},
        tooltip: {
            formatter: function (t) {
                if (t.data.an) {
                    var f = [];
                    cmm.strDgLen(t.data.an, f, 25);
                    return f.join("<br>");
                } else {
                    return t.name;
                }
            }
        },
        series: se
    };
    return option
}

function ybtOption(data, title) {
    var colorTemplate1 = [[1, '#00a2e8']];
    var min = 0;
    var max = 100;
    if (data) {
        if (data != 0) {
            if (data > 0) {
                min = 0;
                if (data > 100) {
                    max = parseInt(data, 10) + 10;
                }
            } else {
                min = parseInt(data) - 10;
            }
        }
    }
    var option = {
        tooltip: {
            formatter: "{a} <br/>{b} : {c}%"
        },
        toolbox: {
            show: false,
            feature: {
                restore: {},
                saveAsImage: {}
            }
        },
        title: {
            text: ''
        },
        series: [
            {
                name: '业务指标',
                type: 'gauge',
                radius: "100%",
                min: min,
                max: max,
                startAngle: 210,
                endAngle: -30,
                detail: {formatter: '{value}%'},
                data: [{value: data, name: title}],
                pointer: {
                    show: true
                },
                axisLine: {				// 仪表盘轴线(轮廓线)相关配置。
                    show: true,				// 是否显示仪表盘轴线(轮廓线),默认 true。
                    lineStyle: {			// 仪表盘轴线样式。
                        color: colorTemplate1, 	//仪表盘的轴线可以被分成不同颜色的多段。每段的  结束位置(范围是[0,1]) 和  颜色  可以通过一个数组来表示。默认取值：[[0.2, '#91c7ae'], [0.8, '#63869e'], [1, '#c23531']]
                        // opacity: 1,					//图形透明度。支持从 0 到 1 的数字，为 0 时不绘制该图形。
                        width: 12				//轴线宽度,默认 30。
                        // shadowBlur: 20,				//(发光效果)图形阴影的模糊大小。该属性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起设置图形的阴影效果。
                        // shadowColor: "#fff",		//阴影颜色。支持的格式同color。
                    }
                },
                splitLine: {			// 分隔线样式。
                    show: true,				// 是否显示分隔线,默认 true。
                    length: 12,				// 分隔线线长。支持相对半径的百分比,默认 30。
                    lineStyle: {			// 分隔线样式。
                        color: "#eee",				//线的颜色,默认 #eee。
                        opacity: 1,					//图形透明度。支持从 0 到 1 的数字，为 0 时不绘制该图形。
                        width: 1,					//线度,默认 2。
                        type: "solid",				//线的类型,默认 solid。 此外还有 dashed,dotted
                        shadowBlur: 10,				//(发光效果)图形阴影的模糊大小。该属性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起设置图形的阴影效果。
                        shadowColor: "#fff"		//阴影颜色。支持的格式同color。
                    }
                },
                axisTick: {				// 刻度(线)样式。
                    show: true,				// 是否显示刻度(线),默认 true。
                    splitNumber: 5,			// 分隔线之间分割的刻度数,默认 5。
                    length: 8,				// 刻度线长。支持相对半径的百分比,默认 8。
                    lineStyle: {			// 刻度线样式。
                        color: "#eee",				//线的颜色,默认 #eee。
                        opacity: 1,					//图形透明度。支持从 0 到 1 的数字，为 0 时不绘制该图形。
                        width: 1,					//线度,默认 1。
                        type: "solid",				//线的类型,默认 solid。 此外还有 dashed,dotted
                        shadowBlur: 10,				//(发光效果)图形阴影的模糊大小。该属性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起设置图形的阴影效果。
                        shadowColor: "#fff"		//阴影颜色。支持的格式同color。
                    }
                },

                axisLabel: {			// 刻度标签。
                    show: true,				// 是否显示标签,默认 true。
                    distance: 5,			// 标签与刻度线的距离,默认 5。
                    color: "#333",			// 文字的颜色,默认 #fff。
                    fontSize: 8,			// 文字的字体大小,默认 5。
                    formatter: "{value}"	// 刻度标签的内容格式器，支持字符串模板和回调函数两种形式。 示例:// 使用字符串模板，模板变量为刻度默认标签 {value},如:formatter: '{value} kg'; // 使用函数模板，函数参数分别为刻度数值,如formatter: function (value) {return value + 'km/h';}
                },
                title: {				// 仪表盘标题。
                    show: true,				// 是否显示标题,默认 true。
                    offsetCenter: [0, "55%"],//相对于仪表盘中心的偏移位置，数组第一项是水平方向的偏移，第二项是垂直方向的偏移。可以是绝对的数值，也可以是相对于仪表盘半径的百分比。
                    color: "#000",			// 文字的颜色,默认 #333。
                    fontSize: 12			// 文字的字体大小,默认 15。
                },

                detail: {				// 仪表盘详情，用于显示数据。
                    show: true,				// 是否显示详情,默认 true。
                    offsetCenter: [0, "30%"],// 相对于仪表盘中心的偏移位置，数组第一项是水平方向的偏移，第二项是垂直方向的偏移。可以是绝对的数值，也可以是相对于仪表盘半径的百分比。
                    color: "auto",			// 文字的颜色,默认 auto。
                    fontSize: 12,			// 文字的字体大小,默认 15。
                    formatter: "{value}%"	// 格式化函数或者字符串
                }
            }
        ]
    }
    return option;
}

function ccxxOption(p_data) {
    return {
        silent: true,
        series: {
            radius: ['15%', '80%'],
            type: 'sunburst',
            sort: null,
            highlightPolicy: 'ancestor',
            data: p_data,
            label: {
                color: '#fff',
                fontSize: 20,
//                textBorderColor: '#8a37e8',
//                textBorderWidth: 10,
//                borderColor: 'yellow',
                borderWidth: 1
            }
        }
    };
}

function zycszbOption(bq) {
    var option = {
        title: {},
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: ['本期']
        },
        toolbox: {
            show: false,
            feature: {
                dataView: {show: true, readOnly: false},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        calculable: true,
        legend: {
            orient: 'horizontal',
            left: 'center',
            show: false,
            bottom: "1%"
        },
        dataZoom: [
            {
                show: true,
                start: 0,
                end: 100
            },
            {
                show: true,
                yAxisIndex: 0,
                filterMode: 'empty',
                width: 30,
                height: '80%',
                showDataShadow: false,
                left: '0%'
            }
        ],
        grid: {
            left: 140,
            top: '2%',
            right: 50,
            bottom: 80
        },
        xAxis: {
            type: 'value',
        },
        yAxis: {

            type: 'category',
            data: ['注册资金', '本年累计销售收入', '本年累计利润额', '本年累计纳税金额', '累计欠税金额', '本年累计减免金额']
        },
        series: [
            {
                name: '本期',
                type: 'bar',
                barWidth: '30%',
                data: bq

            }
        ], barWidth: "20%"
    };
    return option;
}

function srgcOption(data) {
    var yysr = 0;
    var yywsr = 0;
    var tzlr = 0;
    if (data != null) {
        yysr = data.yysr;
        yywsr = data.yywsr;
        if (data.tzlr) {
            tzlr = data.tzlr;
        }
    }
    var total = yysr + yywsr + tzlr;
    var yysrbf = 0;
    var yywsrbf = 0;
    var tzlrbf = 0;
    if (total > 0) {
        yysrbf = new BigDecimal(yysr).divide(total).multiply(100).toFixed(2);
        yywsrbf = new BigDecimal(yywsr).divide(total).multiply(100).toFixed(2);
        tzlrbf = new BigDecimal(tzlr).divide(total).multiply(100).toFixed(2);
    }
    var option = {
        title: {
            x: 'center'
        },
        tooltip: {
            trigger: 'item',
            formatter: "{b} : {c}"
        },
        legend: {
            orient: 'horizontal',
            left: 'left',
            bottom: "1%"
        },
        series: [
            {
                type: 'pie',
                radius: ['50%', '70%'],
                center: ['50%', '35%'],
                data: [
                    {value: yysr, name: '营业收入（' + yysrbf + "%" + "）"},
                    {value: yywsr, name: '营业外收入（' + yywsrbf + "%" + "）"},
                    {value: tzlr, name: '投资利益（' + tzlrbf + "%" + "）"}
                ],
                label: {
                    normal: {
                        show: false,
                        position: 'center'
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '12',
                            fontWeight: 'bold'
                        }
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    return option;
}

function lineOption(yfsj, vl, leg) {
    var option = {
        title: {},
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            orient: 'horizontal',
            left: 'center',
            bottom: "1%",
            data: [leg]
        },
        grid: {
            top: '8%'
        },
        toolbox: {
            show: false
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: yfsj
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                formatter: '{value}'
            }
        },
        series: [
            {
                name: leg,
                type: 'line',
                data: vl,
                markPoint: {
                    data: [
                        {type: 'max', name: '最大值'},
                        {type: 'min', name: '最小值'}
                    ]
                    , symbolSize: 30
                },
                markLine: {
                    data: [
                        {type: 'average', name: '平均值'}
                    ]

                }
            }
        ]
    };
    return option;
}

function jcsrOption(data) {
    var cbsk = 0;
    var cbznj = 0;
    var cbfk = 0;
    if (data != null) {
        cbsk = cmm.isNUllZro(data.cbsk)
        cbznj = cmm.isNUllZro(data.cbznj)
        cbfk = cmm.isNUllZro(data.cbfk)
    }
    var total = cbfk + cbznj + cbsk;
    var cbfkbl = 0;
    var cbznjbl = 0;
    var cbskbl = 0;
    if (total > 0) {
        cbfkbl = new BigDecimal(cbfk).divide(total).multiply(100).toFixed(2);
        cbznjbl = new BigDecimal(cbznj).divide(total).multiply(100).toFixed(2);
        cbskbl = new BigDecimal(cbsk).divide(total).multiply(100).toFixed(2);
    }
    var option = {
        title: {
            x: 'center'
        },
        legend: {
            orient: 'horizontal',
            left: 'left',
            bottom: "1%"
        },

        tooltip: {
            trigger: 'item',
            formatter: "{b} : {c}"
        },
        series: [
            {
                type: 'pie',
                radius: '55%',
                center: ['40%', '50%'],
                data: [
                    {value: cbsk, name: '查补税款（' + cbskbl + "%）"},
                    {value: cbznj, name: '查补滞纳金（' + cbznjbl + "%)"},
                    {value: cbfk, name: '查补罚款（' + cbfkbl + "%）"}
                ],
                label: {
                    normal: {
                        show: false,
                        position: 'outSide',
                        formatter: "{b}, {d}%"
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    return option;
}

function fptjOption(data, v) {
    var total = 0;
    var y = data[0].value;
    var e = data[1].value;
    total = y + e;
    if (total > 0) {
        var ybl = new BigDecimal(data[0].value).divide(total).multiply(100).toFixed(2);
        data[0].name = data[0].name + "（" + ybl + "%）";
        var ebl = new BigDecimal(data[1].value).divide(total).multiply(100).toFixed(2);
        data[1].name = data[1].name + "（" + ebl + "%）";
    }
    var option = {
            title: {
                x: 'center'
            },
            tooltip: {
                trigger: 'item',
                formatter: "{b} : {c}" + v
            },
            legend: {
                orient: 'horizontal',
                left: 'center',
                bottom: "1%"
            },
            series: [
                {
                    type: 'pie',
                    radius: '60%',
                    center: ['50%', '45%'],
                    data: data,
                    fontSize: 8,
                    label: {
                        normal: {
                            show: false,
                            position: 'outSide',
                            formatter: "{b}, {d}%"
                        }
                    },
                    labelLine: {
                        normal: {
                            show: false
                        }
                    },
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        }
    ;
    return option;
}

function kpzyzbOption(qyzb, hyzb) {
    var option = {
        title: {},
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            orient: 'horizontal',
            left: 'center',
            bottom: "1%",
            data: ['企业指标', '行业均值']
        },

        toolbox: {
            show: false
        },
        xAxis: {
            type: 'category',
            data: ["未开具发票", "夜间开票", "顶额开票", "作废发票"]
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                formatter: '{value}'
            }
        },
        series: [
            {
                name: '企业指标',
                type: 'bar',
                data: qyzb,
                barWidth: '15%',
                markPoint: {
                    data: [
                        {type: 'max', name: '最大值'},
                        {type: 'min', name: '最小值'}
                    ]
                },
                markLine: {
                    data: [
                        {type: 'average', name: '平均值'}
                    ]
                }
            },
            {
                name: '行业均值',
                type: 'bar',
                data: hyzb,
                barWidth: '15%',
                markPoint: {
                    data: [
                        {type: 'max', name: '最大值'},
                        {type: 'min', name: '最小值'}
                    ]
                },
                markLine: {
                    data: [
                        {type: 'average', name: '平均值'}
                    ]
                }
            }
        ]
    };
    return option;
}

function xshjxOption(xas, hwd) {
    var option = {
        title: {},
        tooltip: {
            trigger: 'axis'
        },
        toolbox: {
            show: false
        },
        xAxis: {
            type: 'category',
            data: xas,
            axisLabel: {
                interval: 0,
                rotate: 40,
                formatter: function (v) {
                    var k = [];
                    if (v.length > 7) {
                        k.push(v.substring(0, 7));
                        k.push(v.substring(7));
                        return k.join("\n");
                    } else {
                        return v;
                    }
                }
            }
        },
        dataZoom: {
            showDetail: false,
            zoomLock: false,
            height: 18,
            realtime: true,
            start: 0,
            end: 70,
            handleSize: 4
        },
        grid: {
            top: '10%',
            left: '5%',
            right: '2%',
            containLabel: true
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                formatter: '{value}'
            }
        },
        series: [
            {
                name: '货物',
                type: 'bar',
                barWidth: "20%",
                data: hwd
            }
        ]
    };
    return option;
}

function xhghfxOption(data, total) {
    for (var f in data) {
        data[f].name = data[f].name + "（" + new BigDecimal(data[f].value).divide(total).multiply(100).toFixed(3) + "%）";
    }
    var option = {
        title: {
            x: 'center'
        },
        legend: {
            type: 'scroll',
            orient: 'horizontal',
            left: 'center',
            bottom: "1%"
        },
        tooltip: {
            trigger: 'item',
            formatter: "{b} : {c}"
        },
        series: [
            {
                type: 'pie',
                radius: '55%',
                center: ['50%', '45%'],
                data: data,
                label: {
                    normal: {
                        show: false,
                        position: 'outSide',
                        formatter: "{b}, {d}%"
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    return option;
}

function ssfxOption(ld, data) {
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a}: {c} ({d}%)"
        },
        legend: {
            type: 'scroll',
            orient: 'horizontal',
            left: 'center',
            bottom: "1%",
            data: ld,
            formatter: function (name) {
                var f = [];
                cmm.strDgLen(name, f);
                return f.join("\n")
            }
        },
        series: [
            {
                name: '涉税风险',
                type: 'pie',
                radius: ['50%', '70%'],
                avoidLabelOverlap: false,
                label: {
                    normal: {
                        show: true,
                        position: 'inner',
                        formatter: '{c}'
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '30',
                            fontWeight: 'bold'
                        }
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                data: data
            }
        ]
    };
    return option;
}

function getDlLegth(xr) {
    var ds = xr.data;
    var g1 = ds.g1;
    var ss = [];
    var le = [];

    for (var s in g1) {
        ss.push(g1[s].dl);
    }

    for (var i = 0; i < ss.length; i++) {
        for (var j = i + 1; j < ss.length; j++) {
            var b = le.indexOf();
            if (ss[i] === ss[j]) {
                ++i;
            }
        }
        le.push(ss[i]);
    }
    return le.length;
}

function queryQyxxByDjxh(djxh,bdDm){
    var lay = layer.load({shade: [0.1]});
    $.ajax({
        url: ctx + "/mge/adx/syfx/qyhx/queryQyxxByDjxh",
        data:{s_name:djxh,sd1:bdDm},
        type: 'post',
        dataType: 'json',
        success: function (data, sta) {
            layer.close(lay);
            if (data != null && data.code == '200') {
                var dc = data.data;

            } else {
                layer.alert(data.message);
            }
        }, error: function (sta) {
            layer.close(lay);
            layer.alert("请求失败，请重试或检查网络！");
        }
    })
}